<template>
  <div class="yj-data-form">
    <el-form
      size="medium"
      type="flex"
      :model="ruleForm"
      :rules="rules"
      ref="ruleForm"
      label-width="200px"
    >
      <!-- 
          <el-col :sm="12">
          <el-form-item prop="JRXKZH" label="金融许可证号">
            <el-input
              style="width: 300px"
              v-model.trim="ruleForm.JRXKZH"
            ></el-input>
          </el-form-item>
        </el-col> -->

      <el-col :sm="12">
        <el-form-item prop="name" label="岗位名称">
          <el-input
            maxlength="30"
            style="width: 300px"
            v-model.trim="ruleForm.name"
          ></el-input>
        </el-form-item>
      </el-col>

      <el-col :sm="12">
        <el-form-item prop="jobSort" label="排序">
          <el-input-number
            style="width: 300px"
            :min="1"
            :max="999"
            v-model.trim="ruleForm.jobSort"
          ></el-input-number>
        </el-form-item>
      </el-col>

      <el-col :sm="12">
        <el-form-item prop="enabled" label="岗位状态">
          <!-- <el-checkbox v-model.trim="ruleForm.enabled">启用</el-checkbox> -->
          <el-switch
            v-model="ruleForm.enabled"
            active-color="#13ce66"
            inactive-color="#ff4949"
          >
          </el-switch>
        </el-form-item>
      </el-col>
    </el-form>
  </div>
</template>

<script>
export default {
  name: "sysjobForm",
  props: ["flag", "item"],
  data() {
    return {
      formDisableFlag: false,
      ruleForm: {
        oid: "",
        name: "",
        enabled: "",
        jobSort: "1",
        createTime: "",
        updateTime: ""
      },
      rules: {
        CHECK_ID: [
          // { required: true, message: "不能为空", trigger: "blur" }
        ],

        jobId: [
          // { required: true, message: "不能为空", trigger: "blur" }
        ],

        name: [{ required: true, message: "不能为空", trigger: "blur" }],

        enabled: [{ required: true, message: "不能为空", trigger: "blur" }],

        jobSort: [{ required: true, message: "不能为空", trigger: "blur" }],

        createBy: [
          // { required: true, message: "不能为空", trigger: "blur" }
        ],

        updateBy: [
          // { required: true, message: "不能为空", trigger: "blur" }
        ],

        createTime: [
          // { required: true, message: "不能为空", trigger: "blur" }
        ],

        updateTime: [
          // { required: true, message: "不能为空", trigger: "blur" }
        ]
      }
    };
  },
  methods: {
    goAdd() {
      // Object.keys(this.ruleForm).forEach(key => (this.ruleForm[key] = ""));
      this.$refs.ruleForm.resetFields();
      this.ruleForm.enabled = true;
    },
    goUpdate() {
      //   Object.keys(this.ruleForm).forEach(key => (this.ruleForm[key] = ""));
      //   //   this.dialogFormVisible = true;
      //   this.ruleForm.enabled = true;
    },
    validateIt() {
      this.$refs["ruleForm"].validate(valid => {
        if (valid) {
          this.$emit("goSave", null);
        }
      });
    }
  },
  mounted() {
    this.ruleForm = this.item;
    if ("add" === this.flag) {
      this.goAdd();
    }
    if ("view" === this.flag) {
      this.formDisableFlag = true;
    }

    // if ("update" === this.flag) {
    //   this.goUpdate();
    // }
  }
};
</script>

<style scoped>
/* .yj-data-form { */
/* border: 2px solid green; */
/* width: 800px; */
/* margin: 2px auto; */
/* } */
</style>
